package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.TicketBean;
import com.project.mapper.ITicketMapper;
import com.project.service.ITicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class TicketServiceImpl implements ITicketService {
    @Autowired
    private ITicketMapper ticketMapper;
    @Override
    public List<TicketBean> getTicketByStatus(String status) {
        QueryWrapper<TicketBean> qw=new QueryWrapper<>();
        qw.like("t_status",status);
        List<TicketBean> ticketsList=ticketMapper.selectList(qw);
        System.out.println("得到"+ticketsList.size());
        //将新上市改为已上市
        for (TicketBean ticket: ticketsList){
            ticket.setStatus("已上市");
            ticketMapper.updateById(ticket);
        }
        return ticketsList;
    }

}
